import csv
class Student:
    def __init__(self,no,name,age,major):
        self.no = no
        self.name = name
        self.age = age
        self.major = major

    def __str__(self):
        return f"no:{self.no},name:{self.name},age:{self.age},major:{self.major}"

with open("stu.csv","r",encoding="utf-8") as f:
    reader = csv.DictReader(f)
    stus = []
    for row in reader:
        #row是个字典
        stu = Student(row["学号"],row["姓名"],row["年龄"],row["专业"])
        stus.append(stu)
    #遍历输出 stus
    for s in stus:
        print(s)
# print(stu)